package com.luych.toolbox.common.feign.intf.base.service;

import com.luych.toolbox.common.constant.PageConstant;
import com.luych.toolbox.common.feign.FeignInterface;
import com.luych.toolbox.common.feign.param.base.service.RoleParam;
import com.luych.toolbox.common.feign.view.base.service.RoleView;
import com.luych.toolbox.common.page.CommonPageResult;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(contextId = "base-service-role", name = "base-service", path = "/role", decode404 = true)
public interface RoleFeign extends FeignInterface<RoleView, RoleParam> {

    @ApiOperation("按关键字查询用户信息")
    @GetMapping("/search/keyword")
    CommonPageResult<RoleView> pageByKeyword(
            @ApiParam(value = "每页容量") @RequestHeader(name = "pageSize", required = false, defaultValue = PageConstant.DEFAULT_PAGE_SIZE_STR) long pageSize,
            @ApiParam(value = "查询页码") @RequestHeader(name = "pageNumber", required = false, defaultValue = PageConstant.DEFAULT_PAGE_NUMBER_STR) long pageNumber,
            @ApiParam(value = "排序字段") @RequestHeader(name = "sort", required = false, defaultValue = PageConstant.DEFAULT_PAGE_SORT) String sort,
            @ApiParam(value = "正序/倒序，取值ASC/DESC") @RequestHeader(name = "order", required = false, defaultValue = PageConstant.DEFAULT_PAGE_ORDER) String order,
            @ApiParam(value = "查询关键字，支持按角色名模糊查询") @RequestParam(name = "keyword", required = false) String keyword
    );

    @ApiOperation("为角色添加权限")
    @PostMapping("/{roleId}/permission/{permissionId}")
    void addPermission(
            @ApiParam(value = "角色ID") @PathVariable("roleId") String roleId,
            @ApiParam(value = "权限ID") @PathVariable("permissionId") String permissionId
    );

    @ApiOperation("为角色删除权限")
    @DeleteMapping("/{roleId}/permission/{permissionId}")
    void removePermission(
            @ApiParam(value = "角色ID") @PathVariable("roleId") String roleId,
            @ApiParam(value = "权限ID") @PathVariable("permissionId") String permissionId
    );

}
